package com.smashcrush.client.gwt.client.editor;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.TextBox;
import com.smashcrush.model.BrowserType;
import com.smashcrush.model.ScriptSourceType;

public class ScriptEditorGeneralTab extends Composite {

	TextBox nameTextBox;

	ListBox scriptSourceType;

	ListBox browserType;

	TextArea descriptionTextArea;

	public ScriptEditorGeneralTab() {

		FlexTable table = new FlexTable();
		// table.setSize("100%", "50%");

		table.setWidget(1, 0, createLabel("API Name"));
		table.setWidget(1, 1, createNameTextBox());

		table.setWidget(2, 0, createLabel("Language"));
		table.setWidget(2, 1, createScriptSourceType());

		table.setWidget(3, 0, createLabel("Browser Type"));
		table.setWidget(3, 1, createBrowserType());

		table.setWidget(4, 0, createLabel("Description"));
		table.setWidget(4, 1, createDescriptionTextArea());

		initWidget(table);
	}

	private Label createLabel(String name) {
		Label lbl = new Label(name);
		lbl.setStylePrimaryName("formLabel");
		// lbl.setWidth("150px");
		return lbl;
	}

	private TextBox createNameTextBox() {
		nameTextBox = new TextBox();
		return nameTextBox;
	}

	private ListBox createScriptSourceType() {
		scriptSourceType = new ListBox();

		for (ScriptSourceType type : ScriptSourceType.values()) {
			scriptSourceType.addItem(type.toString());
		}

		return scriptSourceType;
	}

	private ListBox createBrowserType() {
		browserType = new ListBox();

		for (BrowserType type : BrowserType.values()) {
			browserType.addItem(type.toString());
		}

		return browserType;
	}

	private TextArea createDescriptionTextArea() {
		descriptionTextArea = new TextArea();
		return descriptionTextArea;
	}

	public TextBox getNameTextBox() {
		return nameTextBox;
	}

	public ListBox getScriptSourceType() {
		return scriptSourceType;
	}

	public TextArea getDescriptionTextArea() {
		return descriptionTextArea;
	}

	public ListBox getBrowserType() {
		return browserType;
	}

}
